/*
 * @Author: your name
 * @Date: 2020-08-16 14:08:01
 * @LastEditTime: 2020-08-16 14:40:39
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \demo\day02\demo06\main.go
 */
package main

import (
	"fmt"
	"io"
	"os"
)

type LoggerManger interface {
	PrintStdder(string)
	PrintFile(string)
}

type Logger struct{}

var file *os.File

func init() {

	file, _ = os.OpenFile("./124.log", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)

}

func NewLogger() *Logger {
	return &Logger{}
}

func (l Logger) PrintStdder(info string) {
	fmt.Println(info)
}

func (l Logger) PrintFile(info string) {
	defer file.Close()
	io.WriteString(file, info)
}

func LoggerInfo(info interface{}) {
	var m LoggerManger
	m = NewLogger()
	switch v := info.(type) {
	case string:
		m.PrintStdder(v)
		m.PrintFile(v)
	default:
		panic(info)
	}
}
func main() {
	LoggerInfo("ffff")
}
